import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';

class Ushare {
  static const MethodChannel _channel = const MethodChannel('ushare');

  static Future<String> init(
      {@required String appKey,
      @required String appSecret,
      @required String wxAppid,
      @required String wxSecret,
      @required String qqAppid,
      @required String weiboAppid,
      String channel = "Umeng",
      bool loggerEnable = true}) async {
    Map<dynamic, dynamic> params = {
      'appKey': appKey,
      'appSecret': appSecret,
      'channel': channel,
      'loggerEnable': loggerEnable,
      'wxAppid': wxAppid,
      'wxSecret': wxSecret,
      'qqAppid': qqAppid,
      'weiboAppid': weiboAppid
    };

    return _channel.invokeMethod('init', params);
  }

  static Future<String> doShare(
      {@required String title,
      @required String desc,
      @required String url,
      @required String imageUrl,
      @required int platform}) async {
    Map<dynamic, dynamic> params = {
      'title': title,
      'desc': desc,
      'url': url,
      'imageUrl': imageUrl,
      'platform': platform
    };
    return _channel.invokeMethod('share', params);
  }
}
